<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%String path = request.getContextPath() ;%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<title>档案面对面借阅列表</title>
	<jsp:include page="../../import.jsp" flush="true" />
	<jsp:include page="../common/warrantCommFunction.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div class="searchArea">
			<!-- 搜索表单开始 -->
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="FXBR">
						<div class="fieldBox">
							<div class="label">档案柜编号</div>
							<div class="field">
								<input type="text" id="cabinetNo" name="cabinetNo" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">档案袋编号</div>
							<div class="field">
								<input type="text" id="portfolioNumber" name="portfolioNumber" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">支付表编号</div>
							<div class="field">
								<input type="text" id="paylistCode" name="paylistCode" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">是否需归还</div>
							<div class="field">
								<select name="isRevert" id="isRevert" ligerui="width: 160">
									<option value="" seleted>请选择</option>
									<option value="1">是</option>
									<option value="0">否</option>
								</select>
							</div>
						</div>
					</div>
					
					<div class="clearFix"></div>
					
					<!-- 表单按钮 -->
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round">查询</span>
						<span id="clearBtn" class="sq-button-round">清空</span>
						<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
						<span id="addBtn" class="sq-button-round" onclick="save('');">新增</span>
		            </div>
		            
				</div>
			</form>
			<!-- 搜索表单结束 -->
		</div>
		<!-- 列表显示块 -->
		<div id="ligergrid1" class="sq-grid"></div>
	</div>
	
	<script type="text/javascript">
		var grid = null;
		//加载
		$(function () {
			$("#searchBar").ligerForm();//初始化表单
		    initGrid();//初始化列表
		    searchBtnEvent();//查询按钮事件
		    clearBtnEvent();//清空按钮事件
		});
		
		//查询参数
		function getSearchParams(){
			var form = new liger.get("searchBar");
			var data = form.getData();
			return data;
		}
		
		//初始化列表
		function initGrid(){
			$("#ligergrid1").ligerGrid({
				url:'<%=path%>/archive/arcBorrowFace/initList.do',
				method:'get',
				parms:getSearchParams(),
				columns:[
					{ display: '借阅人', name: 'borrower', align:'center', enabledSort:true},
					{ display: '联系电话', name: 'contactPhone', width: 120, align:'center', enabledSort:true},
					{ display: '借阅日期', name: 'borrowDate', align:'center', enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = renderDate1(rowdata.borrowDate);
							return h;
						}},
					{ display: '档案柜编号', name: 'cabinetNo', width: 140, align:'center', enabledSort:true},
					{ display: '档案袋编号', name: 'portfolioNumber', width: 140, align:'center', enabledSort:true},
					{ display: '支付表编号', name: 'paylistCode', width: 180, align:'center', enabledSort:true},
					{ display: '借阅资料描述', name: 'borrowDes', width: 180, align:'center', enabledSort:true},
					{ display: '借阅用途', name: 'borrowUse', align:'center', enabledSort:true},
					{ display: '是否需归还', name: 'isRevert', align:'center', enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '是';
							if(rowdata.isRevert != 1){//数值型
								h = '否';
							}
							return h;
						}},
					{ display: '归还时间', name: 'revertDate', align:'center', enabledSort:true,
							render: function (rowdata, rowindex, value, column) { 
								var h = renderDate1(rowdata.revertDate);
								return h;
							}},
					{ display: '借阅登记人', name: 'borrowBooker', align:'center', enabledSort:true},
					{ display:'操作', isSort:false, width: 140, align:'center', 
						render:function (rowdata, rowindex, value){
							var h="";
				            	h+='<a class="sq-button-hasicon" href="javascript:save(';
				                h+="'"+rowdata.id+"'";
				                h+=")\"><i class='sqBtnIco_4'></i>修改</a>";
							
				                h+='<a class="sq-button-hasicon" href="javascript:removeById(';
				                h+="'"+rowdata.id+"'";
				                h+=")\"><i class='sqBtnIco_7'></i>删除</a>";
				                
							return h;
						}
					}
				],
				pageSize:10,
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				height:'100%',
				heightDiff:-2,
				//checkbox:true,//列表是否有选择框
				rownumbers:true,//列表是否有行号
				//选择行事件
				onSelectRow: function(rowdata, rowid, rowobj){
					
				},
				//取消选择行事件
				onUnSelectRow : function(rowdata, rowid, rowobj){
					
				}
			});
			grid = liger.get("ligergrid1");
			//grid.setHeight(100);
			//grid.options.isSingleCheck = true;//列表是否为单选
		}
		
		//清空按钮事件
		function clearBtnEvent(){
			$("#clearBtn").click(function(event) {
				$("#resetBtn").click();  //重置 input-text
				var form = liger.get("searchBar");
				form.setData({  //重置select等特殊表单
					"isRevert":""
				});
			});
		}
		
		//查询按钮事件
		function searchBtnEvent(){
			$("#searchBtn").click(function(event) {
				var form = new liger.get("searchBar");
				var data = form.getData();
				//alert(JSON.stringify(data));
				for (name in data){
					grid.setParm(name,data[name]);
				};
				grid.reload();
			});
		}
		
		//面对面借阅信息新增和修改
		function save(id) {
			var title ="修改";
			if(id == "") {
				title ="新增";
			}
			Add_navTab("arcBscInfo"+id, "面对面借阅信息"+title, '<%=path%>/archive/arcBorrowFace/toSave.do?id='+id , function () {
				grid.reload();
			});
		}
		
		//删除
		function removeById(id) {
			$.ligerDialog.confirm('确定删除吗?', function (flag) {
				if(flag == false)return;
				var wait_dialog=null;
				$.ajax({
					type: 'post',
					dataType:'json',
					url: '<%=path%>/archive/arcBorrowFace/removeById.do?id='+id,
					beforeSend: function(){
				          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				     },
					success:function(msg){
						wait_dialog.close();
						 if(msg.success == 1){
							 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
							 grid.reload();
						 }else{
							 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
						 }
					}
				});
			});
		}
	</script>
</body>
</html>